package com.baizhi.action;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

import java.io.FileInputStream;
import java.io.InputStream;

public class DownloadAction extends ActionSupport {
    private String fileName;
    private String realPath;

    public InputStream getInputStream() throws Exception{

        System.out.println(fileName);
        String path = ServletActionContext.getRequest().getSession().getServletContext().getRealPath(realPath);
        System.out.println(path);
        return new FileInputStream(path+"\\"+fileName);

    }


    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getRealPath() {
        return realPath;
    }

    public void setRealPath(String realPath) {
        this.realPath = realPath;
    }
}
